<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>UUID生成器</title>
<link rel="stylesheet" type="text/css"
	href="${_siteThemePath}/bootstrap.css" />
<link rel="shortcut icon" href="${_siteThemePath}/img/favicon.ico" />
<script type="text/javascript" src="${_siteJsPath}/jquery.js"></script>
<script type="text/javascript" src="${_siteJsPath}/bootstrap.js"></script>
<style type="text/css">
html,body {
	height: 100%;
}

#wrap {
	min-height: 100%;
	height: auto !important;
	height: 100%;
	margin: 0 auto -60px;
}

#push,#footer {
	height: 60px;
}

#footer {
	background-color: #f5f5f5;
}

.container {
	width: auto;
	max-width: 680px;
}

.container .credit {
	margin: 20px 0;
}
</style>
<script type="text/javascript">
	
	//正整数判定正则
	var numRule = /^[1-9]+[0-9]*]*$/;
	
	function generate() {
		var num = $("#inputNum").val();
		if (!numRule.test(num)) {
			alert("生成数量的格式不正确，只可以是正整数！");
			return;
		}
		var upper = $("#chkUpper").is(':checked') ? 1 : 0;
		var dash = $("#chkDash").is(':checked') ? 0 : 1;
		
		$.ajax({
			url : '${_sitePath}/tools/uuid/generate.html',
			type : 'POST',
			async : true,
			data : {
				uuidNum : num,
				upper : upper,
				dash : dash
			},
			success : function(value) {
				$("#result").val("");
				var uuid = value.split(",");
				var len = uuid.length;
				for (var i = 0; i < len; i ++) {
					$("#result").val($("#result").val() + uuid[i] + "\n");
				}
			},
			error : function(value) {
				alert("系统异常，没有正确返回数据，请联系管理员");
			}
		});
	}
</script>
</head>
<body>
	<div id="wrap">
		<div class="container">
			<ul class="breadcrumb">
				<li><a href="${_sitePath}/index.html">首页</a> <span
					class="divider">/</span></li>
				<li><a href="#">小工具</a> <span class="divider">/</span></li>
				<li class="active">UUID生成器</li>
			</ul>
			<legend>生成选项</legend>
			<form class="form-horizontal">
				<div class="control-group input-append">
					 <label class="control-label" for="inputNum">生成数量</label>
					 <div class="controls">
				     	<input class="input-xlarge" type="text" id="inputNum" value="5">
				     	<span class="add-on">个</span>
				     </div>
				</div>
				<div class="control-group">
		    		<div class="controls">
		      			<label class="checkbox">
		        			<input type="checkbox" id="chkUpper"> 使用大写字母
		     			</label>
		     			<label class="checkbox">
		        			<input type="checkbox" id="chkDash"> 使用破折号
		     			</label>
		     			<button type="button" class="btn" onclick="generate()">产生</button>
		    		</div>
		    	</div>
		    	<div class="control-group">
					 <label class="control-label" for="inputNum">生成结果</label>
					 <div class="controls">
				     	<textarea id="result" rows="8" style="width:300px;"></textarea>
				     </div>
				</div>
			</form>
		</div>
		<div id="push"></div>
	</div>
	<div id="footer">
		<div class="container">
			<p class="muted credit">&copy; 2013 Welsmann.</p>
		</div>
	</div>
</body>
</html>